﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Transport.Admin
{
    public partial class TraCuuTaiXe : System.Web.UI.Page
    {
        TaiXeControl txCtrl;
        PhanCongControl pcCtrl;

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                txCtrl = new TaiXeControl();
                pcCtrl = new PhanCongControl();
                List<tai_xe> ls = txCtrl.listAll();

                if (txt_Begin.Text != "" && txt_End.Text != "")
                {
                    DateTime begin = DateTime.Parse(txt_Begin.Text);
                    DateTime end = DateTime.Parse(txt_End.Text);

                    for (int i = ls.Count - 1; i >= 0; i--)
                    {
                        if (pcCtrl.checkDriverStatus(ls[i].ma_tai_xe, begin, end) == false)
                            ls.RemoveAt(i);
                    }
                }

                string vl = ddl_Status.SelectedValue;
                if (vl != "-1")
                {
                    for (int i = ls.Count - 1; i >= 0; i--)
                    {
                        if (ls[i].tinh_trang != vl)
                            ls.RemoveAt(i);
                    }
                }

                GridView_Driver.DataSource = ls;
                GridView_Driver.DataBind();
            }
            catch (Exception)
            {

            }
        }
    }
}